<?php
class stFacebookFeed_model extends stmodel_2_1{

    public function __construct($config) {
        parent::__construct ( $config );
        $this->setTableName('st_facebook_feed');
        $this->setPrimaryKey('id');
    }
    public function getCustomExcerpt($mycontent, $excerpt = false, $id = 0, $more_link_text = null , $limit = 50){

            if ( null === $more_link_text )
		$more_link_text = __( '(more...)', $config['plugin_name'] );

            if($excerpt){
                if ( preg_match('/<!--more(.*?)?-->/', $mycontent, $matches) ) {
                        $mycontent = explode($matches[0], $mycontent, 2);
                        if ( !empty($matches[1]) && !empty($more_link_text) )
                                $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));

                        $mycontent = $mycontent[0];
                } else {
                        $excerpt_length = $limit;
                        $words = explode(' ', $mycontent, $excerpt_length + 1);
                        if(count($words) > $excerpt_length) :
                                array_pop($words);
                                array_push($words, '...');
                                $mycontent = implode(' ', $words);
                        endif;
                }
                $mycontent .= ' <a onclick="facebook_update(\''.$id.'\')" href="' . get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>";
                $mycontent = strip_shortcodes($mycontent);
                $mycontent = str_replace(']]>', ']]&gt;', $mycontent);
            }else{
                $mycontent = strip_shortcodes($mycontent);
                $mycontent = nl2br($mycontent);

            }
            if($option['image']){
                $mycontent = str_replace('<img ', '<img style="display:none"', $mycontent);
                $mycontent = str_replace('style=', 'style="display:none"', $mycontent);
            }

            return $mycontent;
        }



}